package io.writer;

import framework.AbstractTest;
import io.reader.BufferedInputFile;
import utils.Log;

import java.io.*;

/**
 * Created by shane on 2018/5/20.
 */
public class BufferedWriterDemo extends AbstractTest {
    protected static final String TAG = BufferedWriterDemo.class.getName();

    @Override
    public void test(String[] args) {
        super.test(args);

        String input = getDefInputFile(args);
        String output = getDefOutputFile(args);

        try {
            BufferedReader in = new BufferedReader(new StringReader(BufferedInputFile.read(input)));
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(output)));
            String s;
            int lineNum = 1;
            while ((s = in.readLine()) != null) {
                out.print(String.valueOf(lineNum++));
                out.print(":");
                out.print(s);
                out.print("\n");
            }
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected String getTag() {
        return TAG;
    }
}
